qui(function (require, exports, module) {
    VOD.Util = $.extend(true, {}, EpgWeb.Util, {
        formatter: {
            operate_frame: function (cellvalue, options, rowObject) {
                return '<button type="button" class="btn btn-info" onclick="VOD.Util.delFrame(' + rowObject.index + ')">删除</button>' +
                    '<button  type="button" class="btn" onclick="VOD.Player.reviewOne(\'' + rowObject.sTime + '\',\'' + rowObject.eTime + '\',\'打点\');">预览</button>' +
                    '<button type="button" class="btn" onclick="VOD.Util.fromLIstJump(' + rowObject.sTime + ');" >跳转</button>';
            },
            operate_advert: function (cellvalue, options, rowObject) {
                return '<button type="button" class="btn btn-info" onclick="VOD.Util.delAdvert(' + rowObject.index + ')">删除</button>' +
                    '<button  type="button" class="btn" onclick="VOD.Player.reviewOne(\'' + rowObject.sTime + '\',\'' + rowObject.eTime + '\',\'删除\');">预览</button>' +
                    '<button type="button" class="btn" onclick="VOD.Util.fromLIstJump(' + rowObject.sTime + ');" >跳转</button>';
            },
            news_title: function (cellvalue, options, rowObject) {
                if (cellvalue.length == 0) {
                    return "";
                }
                if (VOD.Config.PageBeanNews == null) {
                    return "";
                }
                var findData = VOD.Config.PageBeanNews.findData("regId", parseInt(rowObject.regId));
                if (findData.showTitle == null) {
                    var titleArr = JSON.parse(cellvalue);
                    if (titleArr.length == 0) {
                        findData.showTitle = "";
                    } else {
                        findData.showTitle = titleArr[0];
                    }
                }
                return '<div style="min-height: 20px;min-width: 100px" aria-describedby="myTitle">' + findData.showTitle + '</div><a style="text-underline-position: below;color:blue" onclick="VOD.Util.AlterTitle(' + rowObject.regId + ' )">选择</a>'
            },
            operate_news: function (cellvalue, options, rowObject) {
                var ret = '<a style="text-underline-position: below;color:blue" onclick="VOD.Util.viewNews(' + rowObject.regId + ' )">预览</a>|' +
                    '<a style="text-underline-position: below;color:blue" onclick="VOD.Util.publishNews(' + rowObject.regId + ' )">发布</a>|' +
                    '<a style="text-underline-position: below;color:blue" onclick="VOD.Util.delNews(' + rowObject.regId + ' )">删除</a>'
                if (rowObject.isMergeMode) {
                    ret += '|<br><a style="text-underline-position: below;color:blue" onclick="VOD.Util.undoMerge(' + rowObject.regId + ' )">撤销合并</a>';
                }
                return ret;
            },


            error_hint: function (cellvalue, options, rowObject) {
                return "";
            },
            news_id: function (cellvalue, options, rowObject) {
                var ret = "";
                ret = "<input type='checkbox' onclick='VOD.Util.doRowSelected(this)' aria-describedby='checked'  value='@val' @checked  >".replace("@checked", (rowObject.checked ? "checked" : "")).replace("@val", cellvalue) + cellvalue
                return ret;
            },
            hidden_news_id: function (cellvalue, options, rowObject) {
                return rowObject.regId;
            }
        },

        getUrlParams: function () {
            // var queryStringArr = location.search.match(new RegExp("[\?\&][^\?\&]+=[^\?\&]+", "g")),
            var queryStringArr = decodeURIComponent(location.search).substring(1).split("&"),
                queryStringObj = {}
            var itemArr = [];
            try {
                if (queryStringArr != null) {
                    for (var i = 0; i < queryStringArr.length; i++) {
                        itemArr = queryStringArr[i].split("=");
                        if (i == 0) {
                            queryStringObj['channel_code'] = itemArr[0];
                            queryStringObj['ip'] = itemArr[1];
                        }
                        else {
                            queryStringObj[itemArr[0]] = itemArr[1];
                        }
                    }
                }
            }
            catch (e) {
                console.log("URL地址参数有误，请确认！")
                //  VOD.Plugin.tips("error","URL地址参数有误，请确认！");
            }
            return queryStringObj;
        },
        LayoutInit: function () {
            $(".tab-content").css({
                height: VOD.Util.getPageRelativeMesurement().height - 300 - 10 - 49 - 20 - 2
            });
            $("#makedImg").css({
                height: VOD.Util.getPageRelativeMesurement().height - 90 - 2
            });
        },
        getUserAgent: function () {
            var ua = navigator.userAgent;

            var result = {
                isStrict: document.compatMode == "CSS1Compat",
                isGecko: /gecko/i.test(ua) && !/like gecko/i.test(ua),
                isWebkit: /webkit/i.test(ua)
            };

            try {
                if (/(\d+\.\d+)/.test(external.max_version)) {
                    result.maxthon = +RegExp['\x241'];
                }
            } catch (e) {
                console.log(e);
            }

            if (/msie (\d+\.\d+)/i.test(ua)) {
                result.ie = document.documentMode || +RegExp['\x241'];
            } else if (/trident(\.*?)/i.test(ua)) {
                result.ie = document.documentMode || +RegExp['\x241'];
            } else if (/chrome\/(\d+\.\d+)/i.test(ua)) {
                result.chrome = +RegExp['\x241'];
            } else if (/(\d+\.\d)?(?:\.\d)?\s+safari\/?(\d+\.\d+)?/i.test(ua) && !/chrome/i.test(ua)) {
                result.safari = +(RegExp['\x241'] || RegExp['\x242']);
            } else if (/firefox\/(\d+\.\d+)/i.test(ua)) {
                result.firefox = +RegExp['\x241'];
            } else if (/opera(?:\/| )(\d+(?:\.\d+)?)(.+?(version\/(\d+(?:\.\d+)?)))?/i.test(ua)) {
                result.opera = +(RegExp["\x244"] || RegExp["\x241"]);
            }

            return result;
        },
        detectBrowserSupport: function (browser) {
            var support = false;
            if (browser.isWebkit || browser.firefox) {
                support = true;
            }
            if (browser.ie && browser.ie >= 9) {
                support = true;
            }
            if (!support) {
                var str = '警告！您使用的浏览器版本过低，为了获得更好使用体验。请使用Chrome、Firefox或IE10浏览器。谢谢！';
                VOD.Plugin.tips("error", str);
            }

        },

        // 加载合作方信息
        setCooperativePartner: function (categoryName) {
            var self = this;
            $('#cp').html("");
            var videoTypeMinusOne = self.isVideoType1();
            if (videoTypeMinusOne) {
                return;
            }
            // 关联合作方信息
            VOD.Dao.getCooperativePartner({
                'channeltype': categoryName,
                'channelalias': VOD.Dao.getParamsData().channel_name,
                'ptype': 'UGC',
                'pageNo': 0,
                'pageSize': 1000
            }, function (cps) {
                if (cps == undefined) {
                    return;
                }
                var cpStr = '<option uid="" partnerId="" episodeType="' + VOD.Config.PGC + '"></option>';
                var i = 0,
                    selected = '';
                $.each(cps, function (i, item) {
                    if (i++ === 0) {
                        selected = "selected";
                    } else {
                        selected = "";
                    }
                    cpStr += '<option uid="' + item.ugcid + '" ' + selected + ' partnerId="' + item.qipuid + '" episodeType="' + VOD.Config.UGC + '">' + item.ugcmsg + '</option>';
                })
                $('#cp').html(cpStr);
            });
        },
        setCooperativePartner_tab3: function (categoryName) {
            var self = this;
            $('#tab3_cp').html("");
            // 关联合作方信息
            VOD.Dao.getCooperativePartner({
                'channeltype': categoryName,
                'channelalias': VOD.Dao.getParamsData().channel_name,
                'ptype': 'UGC',
                'pageNo': 0,
                'pageSize': 1000
            }, function (cps) {
                if (cps == undefined) {
                    return;
                }
                var cpStr = '<option uid="" partnerId="" episodeType="' + VOD.Config.PGC + '"></option>';
                var i = 0,
                    selected = '';
                $.each(cps, function (i, item) {
                    if (i++ === 0) {
                        selected = "selected";
                    } else {
                        selected = "";
                    }
                    cpStr += '<option uid="' + item.ugcid + '" ' + selected + ' partnerId="' + item.qipuid + '" episodeType="' + VOD.Config.UGC + '">' + item.ugcmsg + '</option>';
                })
                $('#tab3_cp').html(cpStr);
            });
        },

        compareTime: function (beginTime, endTime) {

            var beginTimes = beginTime.substring(0, 10).split('-');
            var endTimes = endTime.substring(0, 10).split('-');

            beginTime = beginTimes[1] + '-' + beginTimes[2] + '-' + beginTimes[0] + ' ' + beginTime.substring(10, 19);
            endTime = endTimes[1] + '-' + endTimes[2] + '-' + endTimes[0] + ' ' + endTime.substring(10, 19);

            var a = (Date.parse(endTime) - Date.parse(beginTime)) / 3600 / 1000;
            if (a < 0) {
                return -1;
            } else if (a > 0) {
                return 1;
            } else if (a == 0) {
                return 0;
            } else {
                return 'exception'
            }
        },
        detectZoom: function () {
            var ratio = 0,
                screen = window.screen,
                ua = navigator.userAgent.toLowerCase();

            if (window.devicePixelRatio !== undefined) {
                ratio = window.devicePixelRatio;
            } else if (~ua.indexOf('msie')) {
                if (screen.deviceXDPI && screen.logicalXDPI) {
                    ratio = screen.deviceXDPI / screen.logicalXDPI;
                }
            } else if (window.outerWidth !== undefined && window.innerWidth !== undefined) {
                ratio = window.outerWidth / window.innerWidth;
            }

            if (ratio) {
                ratio = Math.round(ratio * 100);
            }

            return ratio;
        },
        browserZoomTips: function () {
            $('[role=alert1]').hide();
            if (VOD.Util.detectZoom() > 100) {
                $('[role=alert]').html(VOD.Config.ZOOM_HINT.BIG).show();
            } else if (VOD.Util.detectZoom() < 100) {
                $('[role=alert]').html(VOD.Config.ZOOM_HINT.SMALL).show();
            } else {
                $('[role=alert]').html("").hide();
            }
        },

        // tab标签上自动拆条可用与否
        autoSegmentationTabOptions: function (options) {
            var defaults = {
                name: ''
            };
            options = $.extend({}, defaults, options);

            if (options.name == 'auto-segmentation-tab') {
                $(".nav-opt").find("input").prop("disabled", false);
                $(".nav-opt").find("button").prop("disabled", false).addClass("nav-opt-enable");
            } else {
                $(".nav-opt").find("input").prop("disabled", true);
                $(".nav-opt").find("button").prop("disabled", true).removeClass("nav-opt-enable");
            }
        },
        getPageRelativeMesurement: function () {
            return {
                width: $(window).width(),
                height: $(window).height()
            };
        },

        isJumpData: function (data, type) {
            if (type == 1) {
                var regJumpData = /^(\d{2}):(\d{2}):(\d{2})$/;
                if (!regJumpData.test(data)) {
                    return false;
                }
                return true;
            } else {
                if (isNaN(data)) {
                    return false;
                }
                return true;
            }
        },
        isVideoType1: function () {
            if ($('input[name=videotype]:checked').val() == -1)
                return 0;
            else
                return 1;
        },

        globalEvent: function (e) {
            console.log("e.keyCode", e.keyCode);
            var self = this;
            var settings = VOD.Dao.settings;
            var global = VOD.Config.Global;
            /*
             // 自动拆条相关
             if (!$('[action-name="segmentation-params-tab"]').parent('li').hasClass('active'))
             return;
             */

            // textarea去除快捷键
            if ($('textarea').is(":focus")) {
                return;
            }
            if ($('input').is(":focus")) {
                return;
            }

            if (e.which == VOD.Config.KEY_CODE.ESC) { // 打点精确化,调出该图片所有上所对应的所有帧  对应快捷键为 ESC
                VOD.AccurateFrame.accurateStartEndRemove();
                return false;
            }

            // 文本框去除快捷键
            if ($("#cForm,#dForm,#tab3").find('input[type=text]').is(":focus")) {
                return;
            }

            if (this.isTab2Show() || this.isTab3Show()) {
                var red = $('.red').parent().find("div");
                if (red.length == 0) {
                    return;
                }
                if (e.which == VOD.Config.KEY_CODE.F) { //打开始
                    //  VOD.AccurateFrame.updateAccurateFrame({head: '', headSetted: false})
                    VOD.NewsHighlight.setNewStart()
                    return;
                }
                if (e.which == VOD.Config.KEY_CODE.D) { //打结束
                    //  VOD.AccurateFrame.updateAccurateFrame({end: '', endSetted: false})
                    VOD.NewsHighlight.setNewEnd()
                    return;
                }
                if (e.which == VOD.Config.KEY_CODE.S) { //打封面
                    VOD.NewsHighlight.setNewImage()
                    return;
                }
            } else {
                if (e.keyCode == VOD.Config.KEY_CODE.R) // ocr快捷键 R
                {
                    if (!self.isVideoType1()) {
                        if ($("#ocr").hasClass("disabled")) {
                            VOD.Plugin.tips("error", '当前ocr不可用！');
                        }
                        else {
                            $("#ocr").trigger("click");
                        }
                    }
                    return;
                }

                if (e.which == VOD.Config.KEY_CODE.ZERO && e.ctrlKey) {
                    $('[role="alert"]').hide();
                    return;
                }

                if (e.which == VOD.Config.KEY_CODE.Z) { //提交删除
                    if (self.del_submit()) {
                        //alert('删除成功');
                        VOD.Plugin.tips("success", "删除成功");
                    }
                    return;
                }

                if (e.which == VOD.Config.KEY_CODE.A) { //提交打点
                    if (self.dot_submit()) {
                        //alert('打点成功');
                        VOD.Plugin.tips("success", "打点成功");
                    }
                    $('#addInfo').removeAttr('disabled').html('提交');
                    return;
                }

                if (e.which == VOD.Config.KEY_CODE.V) { //删除开始
                    if (settings.stime >= 0) {
                        var red = $('.red').parent().find("div");

                        if (red.hasClass('ad-l') || red.hasClass('fragment-r') || red.hasClass('fragment-l')) {
                            return false;
                        }

                        $('.ad-l').remove();
                        if (!$('.old').hasClass('ad-l') && !$('.old').hasClass('ad-r') && $('.old').hasClass('fragment-r') && $('.old').hasClass('fragment-l')) {
                            $('.old').remove();
                        }
                        $('.red').addClass('ad-l');
                        $('.ad-l').removeClass('ad-r');
                        $('.ad-l').html("广<br />告<br />头");
                        $('input[name=d_sTime]').val(settings.stime);
                    }
                    return;
                }
                if (e.which == VOD.Config.KEY_CODE.C) { //删除结束
                    if (settings.etime >= 0) {
                        var red = $('.red').parent().find("div");

                        if (red.hasClass('ad-r') || red.hasClass('fragment-r') || red.hasClass('fragment-l')) {
                            return false;
                        }
                        var tmp_stime = $('input[name=d_sTime]').val();
                        if (tmp_stime.length && parseInt(tmp_stime) > parseInt(settings.etime)) {
                            //alert('起始帧不能大于结束帧!');
                            VOD.Plugin.tips("error", "起始帧不能大于结束帧");
                            return false;
                        }
                        $('.ad-r').remove();
                        if (!$('.old').hasClass('ad-r') && !$('.old').hasClass('ad-l') && $('.old').hasClass('fragment-r') && $('.old').hasClass('fragment-l')) {
                            $('.old').remove();
                        }
                        $('.red').addClass('ad-r');
                        $('.ad-r').removeClass('ad-l');
                        $('.ad-r').html("广<br />告<br />尾");
                        $('input[name=d_eTime]').val(settings.etime);
                    }
                    return;
                }
                if (e.which == VOD.Config.KEY_CODE.F) { //打开始
                    if (settings.stime >= 0) {
                        var red = $('.red').parent().find("div");

                        if (red.hasClass('ad-l') || red.hasClass('ad-r') || red.hasClass('fragment-l')) {
                            return false;
                        }
                        $('.fragment-l').remove();
                        if (!$('.old').hasClass('fragment-l') && !$('.old').hasClass('fragment-r') && $('.old').hasClass('ad-r') && $('.old').hasClass('ad-l')) {
                            $('.old').remove();
                        }

                        $('.red').removeClass('fragment-r');
                        $('.red').addClass('fragment-l');
                        $('.fragment-l').html("片<br />头");
                        $('input[name=sTime]').val(settings.stime);

                        VOD.AccurateFrame.updateAccurateFrame({head: '', headSetted: false})
                    }
                    return;
                }
                if (e.which == VOD.Config.KEY_CODE.D) { //打结束
                    if (settings.etime) {
                        var red = $('.red').parent().find("div");
                        if (red.hasClass('ad-l') || red.hasClass('ad-r') || red.hasClass('fragment-r')) {
                            return false;
                        }
                        tmp_stime = $('input[name=sTime]').val();
                        if (tmp_stime.length && parseInt(tmp_stime) > parseInt(settings.etime)) {
                            //alert('起始帧不能大于结束帧!');
                            VOD.Plugin.tips("error", "起始帧不能大于结束帧");
                            return false;
                        }
                        $('.fragment-r').remove();
                        if (!$('.old').hasClass('fragment-r') && !$('.old').hasClass('fragment-l') && !$('.old').hasClass('ad-l') && !$('.old').hasClass('ad-r')) {
                            $('.old').remove();
                        }

                        $('.red').removeClass('fragment-l');
                        $('.red').addClass('fragment-r');
                        $('.fragment-r').html("片<br />尾");
                        $('input[name=eTime]').val(settings.etime);
                        var s_sTime = $('input[name=sTime]').val();
                        if ($('input[name=videotype]:checked').val() == -1) {
                            var show = settings.taskid + '-' + VOD.Dao.getParamsData().channel_name + '-' + settings.today + '-' + s_sTime + '-' + settings.etime;
                            if ($('input[name=videoName]').val() == "") {
                                $('input[name=videoName]').val(show);
                            }
                            var ocrFirstTitle = VOD.Util.binSearchOcrTitle(tmp_stime, settings.etime).shift();
                            if (ocrFirstTitle) {
                                $("input[name=videoName]").val(ocrFirstTitle);
                                $("input[name=videoName]").attr("eut", encodeURIComponent(ocrFirstTitle));
                            }
                        }
                        VOD.AccurateFrame.updateAccurateFrame({end: '', endSetted: false})

                    }
                    return;
                }
                if (e.which == VOD.Config.KEY_CODE.S) { //打图片
                    if (settings.pic >= 0) {
                        if ($('.layout').hasClass('red block') || $('.layout').hasClass('blue block') || $('.layout').hasClass('red blue yellow block')) {
                            return false;
                        }
                        $('.block').remove();
                        $('.red').addClass('block');
                        $('input[name=imageId]').val(settings.pic);
                    }
                    return;
                }
            }

            if (e.which == VOD.Config.KEY_CODE.Q) { // 打点精确化,调出该图片所有上所对应的所有帧  对应快捷键为 q
                VOD.AccurateFrame.handler_keyCodeQ();
                return;
            }
            if (e.keyCode == VOD.Config.KEY_CODE.W) // 鼠标悬浮快捷键w
            {
                var playOneInfo = VOD.Dao.playOneInfo;
                if (playOneInfo.mouseenter == true) {
                    VOD.Player.updatePosition({left: playOneInfo.left, top: playOneInfo.top})
                    VOD.Player.viewOne(playOneInfo.time);
                }
                return;
            }

            if (e.keyCode == VOD.Config.KEY_CODE.X) // ocr快捷键 x
            {
                VOD.Evt.ShowAndHideSegmentationList();
                return;
            }
            if (e.keyCode == VOD.Config.KEY_CODE.LEFT) { //左
                VOD.Util.dealDirectionKey(VOD.Config.KEY_CODE.LEFT, settings);
                return false;
            }
            if (e.keyCode == VOD.Config.KEY_CODE.RIGHT) { //右
                VOD.Util.dealDirectionKey(VOD.Config.KEY_CODE.RIGHT, settings);
                return false;
            }
            if (e.keyCode == VOD.Config.KEY_CODE.UP) { //上
                VOD.Util.dealDirectionKey(VOD.Config.KEY_CODE.UP, settings);
                return false;
            }
            if (e.keyCode == VOD.Config.KEY_CODE.DOWN) { //下
                VOD.Util.dealDirectionKey(VOD.Config.KEY_CODE.DOWN, settings);
                return false;
            }
        },

        dealDirectionKey: function (arrow, settings) {
            var currentTarget = parseInt($(".red").parent().find(".pid").text().replace(/\s+/g, ""));
            switch (arrow) {
                case   VOD.Config.KEY_CODE.UP:
                    currentTarget = currentTarget - VOD.Dao.settings.linePicNum;
                    break;
                case VOD.Config.KEY_CODE.DOWN:
                    currentTarget = currentTarget + VOD.Dao.settings.linePicNum;
                    break;
                case   VOD.Config.KEY_CODE.LEFT:
                    currentTarget--;
                    break;
                case   VOD.Config.KEY_CODE.RIGHT:
                    currentTarget++;
                    break;
            }
            if (currentTarget < 0) {
                currentTarget = 0;
            }
            $(".red").parent().find(".layout").removeClass("red").addClass("old");
            if (currentTarget >= parseInt($('#picNum').text())) {
                currentTarget = parseInt($('#picNum').text()) - 1;
            }
            settings.pic = settings.etime = settings.stime = currentTarget;
            var newTargetParent = $("#img-" + currentTarget).parent();
            if (newTargetParent.find(".layout").length > 0) {
                newTargetParent.find(".layout").addClass("red");
            } else {
                $(newTargetParent).append(VOD.Config.RED_LAYOUT)
            }
        },
        setHighLight: function (rowData) {
            var options = {};
            options.st = rowData.sTime
            options.et = rowData.eTime
            options.id = rowData.regId
            options.pic = rowData.pic
            options.bgColor = 'cfff';
            options.color = 'c09f';
            VOD.NewsHighlight.setHighLight(options);

        },
        delFrame: function (rowId) {
            SystemDialog.queryConfirm("确认删除么?", function (flag) {
                if (flag === true) {
                    var findData = VOD.Config.PageBeanFrame.findData("index", rowId);
                    if (findData != null) {
                        VOD.Config.PageBeanFrame.delOne(findData)
                        VOD.Util.updateGridFrame();
                        VOD.Util.delOne("打点", findData.sTime, findData.eTime);
                    }
                }
            })
        },

        viewNews: function (rowId) {
            var findData = VOD.Config.PageBeanNews.findData("regId", rowId);
            VOD.Util.doReview(findData.sTime, findData.eTime, false)
        },
        publishNews: function (rowId) {
            VOD.Util.readPublishFrameData(rowId);
            var findData = VOD.Config.PageBeanNews.findData("regId", rowId);
            $("li[aria-controls=tab3]").show();
            var panel = $("#tab3");
            panel.show();
            $("span[name=tabName]").html("序号" + rowId + "发布");
            $("#navDiv").tabs({active: 2});
            panel.find("input[name=tab3_title]").val(findData.showTitle);
            panel.find("input[name=tab3_inpoint]").val(findData.sTime);
            panel.find("input[name=tab3_outpoint]").val(findData.eTime);
            panel.find("input[name=tab3_imageId]").val(findData.pic);
            panel.find("input[name=tab3_priority][value=0]").prop("checked", true);
            panel.find("input[name=tab3_video_dpi][value=3]").prop("checked", true);
            $("#cover_img").attr("src", $("#img-" + findData.pic).attr("src"));
            $("input[name=tab3_categoryName]").suggest("setValue", "");
            $("input[name=tab3_albumName]").suggest("setValue", "");
            panel.find("input[name=tab3_title]").keyup();
        },
        delNews: function (rowId, skipQuery) {
            skipQuery = skipQuery === true ? true : false;
            var findData = VOD.Config.PageBeanNews.findData("regId", rowId);
            var toRemoveArr = [];
            if (findData != null) {
                if (findData.isMergeMode) {
                    if (findData.toRemoveArr.length > 0) {
                        toRemoveArr = findData.toRemoveArr;
                    }
                } else if (findData.id > 0) {
                    toRemoveArr.push(findData.id);
                }
            }
            if (skipQuery) {
                VOD.Util.delNewsMethod(toRemoveArr, findData);
            } else {
                SystemDialog.queryConfirm("确认删除该条新闻么?", function (flag) {
                    if (flag === true) {
                        VOD.Util.delNewsMethod(toRemoveArr, findData);
                    }
                });
            }
        },
        delNewsMethod: function (toRemoveArr, findData) {
            if (toRemoveArr.length == 0) {
                VOD.Util.mergeNewsGridData([], [findData]);
            } else {
                VOD.Dao.delNews({ key: VOD.Dao.settings.taskid, id: toRemoveArr.join(","), status: 2, from_client: true }, function (data) {
                    console.log(JSON.stringify(data));
                    if (data.code == "A00000") {
                        VOD.Plugin.tips("success", data.msg);
                    } else {
                        VOD.Plugin.tips("error", data.msg);
                    }
                    $("button[name=refresh_tab2]").click();
                })
            }
        },
        delAdvert: function (rowId) {
            SystemDialog.queryConfirm("确认删除么?", function (flag) {
                if (flag === true) {
                    var findData = VOD.Config.PageBeanAdvert.findData("index", rowId);
                    if (findData != null) {
                        VOD.Config.PageBeanAdvert.delOne(findData)
                        VOD.Util.updateGridAdvert();
                        VOD.Util.delOne("删除", findData.sTime, findData.eTime);
                    }
                }
            })
        },
        AlterTitle: function (rowId) {
            $("#alter_title-dlg").dialog("open");
            var rowData = VOD.Config.PageBeanNews.findData("regId", rowId);
            var titleArr = JSON.parse(rowData.title);
            $("#alter_title-dlg").find("form").html("");
            var htmlArr = [];
            htmlArr.push('<input name="alter_title_id" type="hidden" value="' + rowId + '" />');
            $.each(titleArr, function (i, element) {
                htmlArr.push('<label><input type="radio" name="alter_title_radio" value="' + element + '" />' + element + '</label>')
            })
            $("#alter_title-dlg").find("form").html(htmlArr.join(""));
        },
        updateNewsFormData: function () {
            var selectedValue = $("input[name=alter_title_radio]:checked").val();
            if (selectedValue == null) {
                return;
            }
            $("input[name=tab3_title]").val(selectedValue);
        },

        updateNewsGridRowData: function () {
            var selectedValue = $("input[name=alter_title_radio]:checked").val();
            if (selectedValue == null) {
                return;
            }
            var elementId = $("input[name=alter_title_id]").val();
            var rowData = VOD.Config.PageBeanNews.findData("regId", elementId);
            if (rowData != null && rowData.showTitle != selectedValue) {
                rowData.showTitle = selectedValue;
                $("#news_list").setRowData(rowData.regId, { title: rowData.title, regId: rowData.regId });
            }
        },
        fromLIstJump: function (index) {
            if (!this.isJumpData(index, 0)) {
                //alert('跳转输入格式错误');
                VOD.Plugin.tips("error", '跳转输入格式错误');
                return false;
            }
            var jumpContent = index + '-jump';
            if ($('.relative').hasClass(jumpContent)) {
                $('#makedImg').scrollTop(0)
                var sTop = $('.' + jumpContent).offset().top - 100;
                $('#makedImg').scrollTop(sTop);
            } else {
                //alert('没有这帧');
                VOD.Plugin.tips("error", '没有这帧');
            }
        },
        initHelp: function () {
            var innerText = "";
            $.each(VOD.Config.HELP_DATA, function (i, data) {
                innerText += '<tr><td>' + data[0] + '</td><td>' + data[1] + '</td></tr>'
            })
            $("#help-dlg").find("tbody").html(innerText);
            if ($("#help2-dlg").length > 0) {
                innerText = "";
                $.each(VOD.Config.HELP2_DATA, function (i, data) {
                    innerText += '<tr><td>' + data[0] + '</td><td>' + data[1] + '</td></tr>'
                })
                $("#help2-dlg").find("tbody").html(innerText);
            }
        },
        validStart: function () {
            var self = this;
            var settings = VOD.Dao.settings;
            if (VOD.Config.EDIT_MODE_TYPE == 1) {
                var s_time = $('#inputStartTime').val();
                var e_time = $('#inputEndTime').val();
                var checkArr = [];
                checkArr.push({value: s_time.length, error: "请先输入起始时间", type: "gt", other: 0 })
                checkArr.push({value: e_time.length, error: "请先输入结束时间", type: "gt", other: 0 })
                checkArr.push({value: s_time, error: "起始时间格式不正确", type: "date"})
                checkArr.push({value: e_time, error: "结束时间格式不正确", type: "date"})
                checkArr.push({value: s_time, error: "开始时间必须小于结束时间", type: "lt", other: e_time })
                checkArr.push({value: s_time, error: "开始时间不能大于当前时间", type: "lt", other: this.formatDateTimeFormat(new Date()) });
                if (!VOD.Plugin.Validate.batchCheck(checkArr)) {
                    console.log("interrupt checkLiveType checkRepeat")
                    return false;
                }
                settings.period = parseInt((self.dateToNumber(e_time) - self.dateToNumber(s_time)) / 1000);
                settings.today = s_time.replace(/-/g, '').substring(0, 8);
                return parseInt(this.dateToNumber(s_time) / 1000);
            } else if (VOD.Config.EDIT_MODE_TYPE == 2) {
                return true;
            }
            return false;

        },
        dateToNumber: function (dString) {
            var toDate = new Date(dString.replace(/-/g, "/"));
            return toDate.getTime();
        },
        getLineWidth: function () {
            var settings = VOD.Dao.settings;
            var lineWidth = $('.img-content').width();
            var picWidth = $('.relative').width();
            settings.linePicNum = parseInt(lineWidth / picWidth);
        },
        addClearFix: function () {
            var cb = 1;
            var global = VOD.Config.Global;
            var settings = VOD.Dao.settings;
            $('#makedImg').find('.text-center').each(function (k, v) {
                s = '<div class="clearfix breakWord">&nbsp;</div>';
                if (global.smallPic) {
                    if (cb % settings.linePicNum == 0) {
                        $(this).after(s);
                    }
                }
                if (!global.smallPic) {
                    if (cb % settings.linePicNum == 0) {
                        $(this).after(s);
                    }
                }
                cb++;
            })
        },
        dl_click: function (clt) {
            try {
                if (clt == '') {
                    return;
                }
                var Then = new Date();
                var continued_time = Math.round((Then.getTime()) / 1000);
                $.get(clt + "&ct=" + continued_time);
            }
            catch (e) {
                console.log("error", e);
            }
        },
        dl_img_click: function (event, viewTime) {
            VOD.Player.view(viewTime)
        },

        validAddInfo: function (data) {
            var v = true;
            $.each(data, function (message, type) {
                if (type == null || type.length == 0) {
                    VOD.Plugin.tips("error", message + '不存在，请重新输入');
                    v = false;
                    return false;
                }
            });
            return v;
        },
        addInfo: function (data, type) {
            data.sTime = parseInt(  data.sTime );
            data.eTime = parseInt(  data.eTime );
            if (type == 'add') {

                //  html = '<tr class="scorll-to-frame" frame-index="' + data.index + '"><td>' + data.index + '</td><td>' + data.sTime + '</td><td>' + data.eTime + '</td><td><div style="padding:0;margin:0;width:124px;overflow:hidden;white-space: nowrap;" title="' + data.title + '">' + data.title + '</div></td><td>' + data.channel + '</td><td>' + data.album + '</td><td>' + data.pic + '</td><td>已生成</td><td><button class="btn btn-info" id="del-' + data.index + '" onclick="if( confirm(\'确认要删除吗?\')){$(this).parent().parent().remove();delOne(\'打点\',\'' + data.sTime + '\',\'' + data.eTime + '\');}">删除</button><a style="margin-left:5px;" onClick="reviewOne(\'' + data.sTime + '\',\'' + data.eTime + '\',\'打点\');" class="btn btn-success">预览</a><a style="margin-left:5px;" onClick="fromLIstJump(\'' + data.sTime + '\');" class="btn btn-success">跳转</a></td></tr>';
                $('#addInfo').html('成功');
                VOD.Config.PageBeanFrame.addNewOne(data);
                VOD.Util.updateGridFrame();
                //   $('#showInfo1').append(html);
            } else {
                //   html = '<tr class="scorll-to-frame" frame-index="' + data.index + '"><td>' + data.index + '</td><td>' + data.sTime + '</td><td>' + data.eTime + '</td><td><div style="padding:0;margin:0;width:124px;overflow:hidden;white-space: nowrap;" title="' + data.title + '">' + data.title + '</div></td><td>已生成</td><td><button class="btn btn-info" id="del-' + data.index + '" onclick="if( confirm(\'确认要删除吗?\')){$(this).parent().parent().remove();delOne(\'删除\',\'' + data.sTime + '\',\'' + data.eTime + '\');}">删除</button><a style="margin-left:5px;" onClick="reviewOne(\'' + data.sTime + '\',\'' + data.eTime + '\',\'删除\');" class="btn btn-success">预览</a><a style="margin-left:5px;" onClick="fromLIstJump(\'' + data.sTime + '\');" class="btn btn-success">跳转</a></td></tr>';
                $('#d_addInfo').html('成功');
                //     $('#showInfo2').append(html);
                VOD.Config.PageBeanAdvert.addNewOne(data);
                VOD.Util.updateGridAdvert();
                var advertSource = VOD.Config.PageBeanAdvert.getSource();
                var temp = [];
                var uniqueArr = [];
                $.each(advertSource, function (i, element) {
                    for (var i = element.sTime; i <= element.eTime; i++) {
                        temp.push(i);
                    }
                })
                $.each(temp, function (i, el) { //去重复
                    if ($.inArray(el, uniqueArr) === -1)
                        uniqueArr.push(el);
                });
                VOD.Dao.settings.delList = uniqueArr;
            }
        },
        delOne: function (type, s, e) {
            var arr3 = [];
            var settings = VOD.Dao.settings;
            if (type == '删除' && settings.delList.length) {
                var advertSource = VOD.Config.PageBeanAdvert.getSource();
                $.each(advertSource, function (i, element) {
                    for (var i = element.sTime; i <= element.eTime; i++) {
                        arr3.push(i);
                    }
                })
//                $('#showInfo2').find('tr').each(function () {
//                    var d_stime = parseInt($(this).children().eq(1).text());
//                    var d_etime = parseInt($(this).children().eq(2).text());
//                    for (var i = d_stime; i <= d_etime; i++) {
//                        arr3.push(i);
//                    }
//                })
                var uniqueArr3 = [];
                $.each(arr3, function (i, el) { //去重复
                    if ($.inArray(el, uniqueArr3) === -1)
                        uniqueArr3.push(el);
                });
                settings.delList = uniqueArr3;
            }
        },

        getDataByNum: function (_num) {
            var day = 864000,
                hour = 3600,
                minute = 60,
                base = 0,
                res = '',
                num = _num;
            if (num >= day) {
                base = parseInt(num / day);
                res += String(base);
                num = num - base * day;
            }
            if (num >= hour) {
                base = parseInt(num / hour);
                if (base < 10) {
                    res += '0';
                }
                res += String(base);
                num = num - base * hour;
                res += ':';
            } else {
                res += '00:';
            }
            if (num >= minute) {
                base = parseInt(num / minute);
                if (base < 10) {
                    res += '0';
                }
                res += String(base);
                num = num - base * minute;
                res += ':';
            } else {
                res += '00:';
            }
            if (num >= 0) {
                if (num < 10) {
                    res += '0';
                }
                res += String(num);
            }
            return res;
        },

        //提交删除
        checkStAndEt: function (stime, etime, plusMsg) {
            plusMsg = plusMsg || "";
            var checkArr = [];
            checkArr.push({value: stime, error: plusMsg + "起始帧有误,必须为数字类型", type: "number"})
            checkArr.push({value: etime, error: plusMsg + "结束帧有误,必须为数字类型", type: "number"})
            checkArr.push({value: parseInt(stime), error: plusMsg + "起始帧不能大于结束帧", type: "le", other: parseInt(etime)  })
            return VOD.Plugin.Validate.batchCheck(checkArr)
        },

        del_submit: function () {
            var d_sTime = $('input[name=d_sTime]').val();
            var d_eTime = $('input[name=d_eTime]').val();
            var d_title = $('input[name=d_videoName]').val();
            //////////////////////////////////////////////////////////
            var d_type = $('input[name=d_imgType]').val();
            //////////////////////////////////////////////////////////
            $('#d_addInfo').attr('disabled', 'disabled');
            var data = {
                '起始帧': d_sTime,
                '结束帧': d_eTime,
                '标题': d_title
            };
            if (!this.checkStAndEt(d_sTime, d_eTime)) {
                console.log("interrupt checkLiveType checkRepeat")
                return false;
            }
            if (!this.validAddInfo(data)) {
                return false;
            }
            var dataSubmit = {
                'index': VOD.Dao.settings.index,
                'sTime': d_sTime,
                'eTime': d_eTime,
                'title': d_title,
                'channel': '',
                'album': '',
                'pic': ''
            }
            VOD.Config.Global.d_sty2Data.push(dataSubmit);
            this.addInfo(dataSubmit, 'del');
            $('input[name=d_sTime]').val('');
            $('input[name=d_eTime]').val('');
            VOD.Dao.settings.index++;
            VOD.AccurateFrame.adTipRemove(); // 广告左右标识删除
            return true;
        },

        //新闻拆条发布
        news_submit: function () {
            var settings = VOD.Dao.settings;
            var paramsData = VOD.Dao.getParamsData();
            var global = VOD.Config.Global;
            if (settings.taskid < 1.) {
                VOD.Plugin.tips("error", '任务ID为空,不能提交!');
                return false;
            }

            var sTime = $('input[name=tab3_inpoint]').val(),
                eTime = $('input[name=tab3_outpoint]').val(),
                title = $('input[name=tab3_title]').val(),
                channel = $('input[name=tab3_categoryName]').suggest("getValue");
            var cpOption = $('#tab3_cp').children('option:selected');
            var album = $('input[name=tab3_albumName]').val(),
                pic = $('input[name=tab3_imageId]').val() ? $('input[name=tab3_imageId]').val() : sTime,
                data = {
                    '起始帧': sTime,
                    '结束帧': eTime,
                    '标题': title,
                    '频道': channel
                },
                dataSubmit = {
                    'index': settings.index,
                    'sTime': sTime,
                    'eTime': eTime,
                    'title': title,
                    'channel': channel,
                    'album': album,
                    'pic': pic
                },
                toLego = true,

                priority = $('input[name=tab3_priority]:checked').val(), //优先级
                video_dpi = $('input[name=tab3_video_dpi]:checked').val(), //分辨率
                uid = cpOption.attr("uid"), //表示ugc用户id
                partnerId = cpOption.attr("partnerId"), //表示合作方id
                episodeType = cpOption.attr("episodeType"); //取值为0或1,1表示为ugc视频，0为普通ppc视频
            uid = !uid ? "" : uid;
            partnerId = !partnerId ? "" : partnerId;
            episodeType = !episodeType ? "" : episodeType;
            var albumId = '';
            if (album) {
                albumId = $('input[name=albumName]').suggest("getValue") || "";
                //  $('input[name=albumId]').val();
            }
            if (!this.checkStAndEt(sTime, eTime)) {
                return false;
            }
            var checkArr = [];
            checkArr.push({value: pic, error: "封面格式有误,必须为数字类型", type: "number"})
            var numTime = $('#picNum').text();
            checkArr.push({value: parseInt(eTime), error: "结束帧不存在,不能提交", type: "le", other: parseInt(numTime)  })
            if (!VOD.Plugin.Validate.batchCheck(checkArr)) {
                console.log("interrupt checkLiveType checkRepeat")
                return false;
            }
            $('#tab3_submit').attr('disabled', 'disabled');
            if (!toLego) {
                return;
            }
            if (!this.validAddInfo(data)) {
                return false;
            }
            if (!VOD.AccurateFrame.isMarkedFrame(parseInt(eTime)) && !VOD.AccurateFrame.getAccurateFrame().endSetted) {
                //alert("请在片尾使用精确化裁剪工具，快捷键Q");
                VOD.Plugin.tips("error", "请在出点使用精确化裁剪工具，快捷键Q");
                return false;
            }

            //去除删除部分
            VOD.Player.splitData(sTime, eTime, true);
            //console.log(subData);
            if (!settings.subData.length) {
                //alert('该条打了删除，不能再打拆条!');
                VOD.Plugin.tips("error", '该条打了删除，不能再打拆条!');
                return false;
            }

            var p_vid = 0;
            var p_albumId = $('input[name=tab3_albumName]').suggest("getValue") || "";

            var rightIdentification = 0,
                options = {};

            var delAdStr = "";
            var adLibList = settings.adLibList;
            var advertSource = VOD.Config.PageBeanAdvert.getSource();
            $.each(advertSource, function (i, element) {
                var s = $('.' + element.sTime + '-jump').attr("id").split("-")[1],
                    e = $('.' + element.eTime + '-jump').attr("id").split("-")[1];


                if (delAdStr != "")
                    delAdStr += ',';

                delAdStr += '0/' + s + '_0/' + e

                for (var dj in adLibList) {
                    if (adLibList[dj].s <= s && adLibList[dj].e >= s) {
                        if (adLibList[dj].s == s && adLibList[dj].e == e) {
                            rightIdentification++;
                        }
                        break;
                    }
                }
            })

            var adLibListLen = 1;
            if (adLibList.length !== 0) {
                adLibListLen = adLibList.length;
            }

            options.from_client = true;  //绕过鉴权
            options.score = rightIdentification / adLibListLen * 10; //  打分是在1~10分之前包括小数
            options.func = "modify_ablum";

            $.ajax({
                cache: false,
                async: false,
                type: "post",
                url: VOD.urlConfig.modifyUrl,
                data: {"channel_id": paramsData._channel_id, "ablum_id": p_albumId, "func": options.func, "score": options.score},
                success: function (res) {
                    console.log("$.ajax 842 success");
                    console.log(res);
                },
                dataType: "json",
                error: function () {
                    //alert('网络错误,请稍后再广告评分入库！');
                    VOD.Plugin.tips("error", '网络错误,请稍后再广告评分入库！');
                }
            });

//////////////////////////////////////////end  todo 还待优化 //////////////////////////////////////////////////////
            var dataJson = {
                'videoId': p_vid,
                'priority': priority,
                'albumName': album,
                'videoName': title,
                'categoryId': channel,
                'albumId': p_albumId,
                'reTranscodeConfirm': VOD.Util.getReTranscodeConfirmVal(),
                'freeType': paramsData.freeType
            };
            if ($("#locationDiv").is(":visible")) {
                dataJson.locationCategory = $("input[name=location]").suggest("getValue");
            }
            $.ajax({
                cache: false,
                async: false,
                type: "post",
                url: VOD.urlConfig.redirect,
                timeout: 10000,
                data: {"request": JSON.stringify({url: VOD.Constant.thirdUrl_legoProgramIdUrl, type: "post", params: {
                    data: JSON.stringify(dataJson)
                }, needCookie: true}), timeSign: new Date().getTime()},
                success: function (res) {
                    if (res.code != 'A00000') {
                        //alert(res.msg);
                        VOD.Plugin.tips("error", res.msg);
                    } else {
                        var programId = res.data.programId;
                        if (!programId) {
                            //alert('乐高返回的programId为空!');
                            VOD.Plugin.tips("error", '乐高返回的programId为空!');
                            return false;
                        }

                        var newPA = {
                            title: title,
                            cat: channel,
                            alb: albumId,
                            enableClound: VOD.Util.getEnableCloundVal(),
                            priority: priority,
                            video_dpi: video_dpi,
                            uid: uid,
                            partnerId: partnerId,
                            episodeType: episodeType
                        }

                        //提交数据给刘之红
                        if (VOD.Util.postData(settings.subData, newPA, pic, programId, dataSubmit)) {
//////////////////////////制作数据统计///////////////////////////////////////////
/////////////////////////////end//////////////////////////////////////////////////////
                            //alert('打点成功');
                            VOD.Plugin.tips("success", '打点成功');
                            VOD.AccurateFrame.doReset();
                            VOD.Util.clearHighLight();
                            return true;
                        }
                    }
                },
                dataType: "json",
                error: function (XMLHttpRequest, status) {
                    //alert('网络错误,请稍后再提交！');
                    if (status == 'timeout') {
                        ajaxTimeoutTest.abort();
                        VOD.Plugin.tips("error", '接口/peditor/submit调用超时10秒未响应！请联系乐高相关负责人员！');
                    } else {
                        VOD.Plugin.tips("error", '网络错误,请稍后再提交！');
                    }
                    $('#tab3_submit').removeAttr('disabled').html('提交');
                }
            });
        },

        //提交拆条
        dot_submit: function () {
            var settings = VOD.Dao.settings;

            var paramsData = VOD.Dao.getParamsData();
            var global = VOD.Config.Global;
            if (settings.taskid < 1.) {
                VOD.Plugin.tips("error", '任务ID为空,不能提交!');
                return false;
            }

            var sTime = $('input[name=sTime]').val(),
                eTime = $('input[name=eTime]').val(),
                title = $('input[name=videoName]').val(),
                channel = $('input[name=categoryName]').suggest("getValue");
            var cpOption = $('#cp').children('option:selected');
            var album = $('input[name=albumName]').val(),
                pic = $('input[name=imageId]').val() ? $('input[name=imageId]').val() : sTime,
                fantasyTitle = $('textarea[name=fantasyTitle]').val() ? $('textarea[name=fantasyTitle]').val() : "",
                data = {
                    '起始帧': sTime,
                    '结束帧': eTime,
                    '标题': title,
                    '频道': channel
                },
                dataSubmit = {
                    'index': settings.index,
                    'sTime': sTime,
                    'eTime': eTime,
                    'title': title,
                    'channel': channel,
                    'album': album,
                    'pic': pic
                },
                toLego = true,

                priority = $('input[name=priority]:checked').val(), //优先级
                video_dpi = $('input[name=video_dpi]:checked').val(), //分辨率
                uid = cpOption.attr("uid"), //表示ugc用户id
                partnerId = cpOption.attr("partnerId"), //表示合作方id
                episodeType = cpOption.attr("episodeType"); //取值为0或1,1表示为ugc视频，0为普通ppc视频
            uid = !uid ? "" : uid;
            partnerId = !partnerId ? "" : partnerId;
            episodeType = !episodeType ? "" : episodeType;
            var albumId = '';
            if (album) {
                albumId = $('input[name=albumName]').suggest("getValue") || "";
                //  $('input[name=albumId]').val();
            }

            if (!this.checkStAndEt(sTime, eTime)) {
                return false;
            }
            var checkArr = [];
            checkArr.push({value: pic, error: "封面格式有误,必须为数字类型", type: "number"})
            var numTime = $('#picNum').text();
            checkArr.push({value: parseInt(eTime), error: "结束帧不存在,不能提交", type: "le", other: parseInt(numTime)  })
            if (!VOD.Plugin.Validate.batchCheck(checkArr)) {
                console.log("interrupt checkLiveType checkRepeat")
                return false;
            }
            $('#addInfo').attr('disabled', 'disabled');

            if (!toLego) {
                return;
            }
            if (!this.validAddInfo(data)) {
                return false;
            }

            if (!VOD.AccurateFrame.getAccurateFrame().endSetted) {
                //alert("请在片尾使用精确化裁剪工具，快捷键Q");
                VOD.Plugin.tips("error", "请在片尾使用精确化裁剪工具，快捷键Q");
                return false;
            }

            //去除删除部分
            VOD.Player.splitData(sTime, eTime, true);
            //console.log(subData);
            if (!settings.subData.length) {
                //alert('该条打了删除，不能再打拆条!');
                VOD.Plugin.tips("error", '该条打了删除，不能再打拆条!');
                return false;
            }

//            if (settings.videonameArr.length) {
//                var exist = false;
//                for (var i in settings.videonameArr) {
//                    if (settings.videonameArr[i] == title) {
//                        exist = true;
//                    }
//                }
//                if (!exist) {
//                    //alert('提交失败，标题不存在!');
//                    VOD.Plugin.tips("error", '提交失败，标题不存在!');
//                    return false;
//                }
//            }

            //提交数据到乐高
            // var p_vid = $('input[name=videoId]').val() ? $('input[name=videoId]').val() : 0;
            var p_vid = $('input[name=videoName]').suggest("getValue") || 0;
            var p_albumId = $('input[name=albumName]').suggest("getValue") || "";
            var videotype = $('input[name=videotype]:checked').val();
            if (videotype == -1) {
                p_vid = 0;
            }

///////////////////////////////   评分   ////////////////////////////////////
            var rightIdentification = 0,
                options = {};

            var delAdStr = "";
            var adLibList = settings.adLibList;
            var advertSource = VOD.Config.PageBeanAdvert.getSource();
            $.each(advertSource, function (i, element) {
                var s = $('.' + element.sTime + '-jump').attr("id").split("-")[1],
                    e = $('.' + element.eTime + '-jump').attr("id").split("-")[1];


                if (delAdStr != "")
                    delAdStr += ',';

                delAdStr += '0/' + s + '_0/' + e

                for (var dj in adLibList) {
                    if (adLibList[dj].s <= s && adLibList[dj].e >= s) {
                        if (adLibList[dj].s == s && adLibList[dj].e == e) {
                            rightIdentification++;
                        }
                        break;
                    }
                }
            })

            var adLibListLen = 1;
            if (adLibList.length !== 0) {
                adLibListLen = adLibList.length;
            }

            options.from_client = true;  //绕过鉴权
            options.score = rightIdentification / adLibListLen * 10; //  打分是在1~10分之前包括小数
            options.func = "modify_ablum";


            $.ajax({
                cache: false,
                async: false,
                type: "post",
                url: VOD.urlConfig.modifyUrl,
                data: {"channel_id": paramsData._channel_id, "ablum_id": p_albumId, "func": options.func, "score": options.score},
                success: function (res) {
                    console.log("$.ajax 842 success");
                    console.log(res);
                },
                dataType: "json",
                error: function () {
                    //alert('网络错误,请稍后再广告评分入库！');
                    VOD.Plugin.tips("error", '网络错误,请稍后再广告评分入库！');
                }
            });

//////////////////////////////////////////end  todo 还待优化 //////////////////////////////////////////////////////

            var dataJson = {
                'videoId': p_vid,
                'priority': priority,
                'albumName': album,
                'videoName': title,
                'categoryId': channel,
                'albumId': p_albumId,
                'reTranscodeConfirm': VOD.Util.getReTranscodeConfirmVal(),
                'freeType': paramsData.freeType
            };
            if ($("#locationDiv").is(":visible")) {
                dataJson.locationCategory = $("input[name=location]").suggest("getValue");
            }
            if (videotype == -1) {
                dataJson.fantasyTitle = fantasyTitle;
            }
            // settings.videonameArr = [];

            $.ajax({
                cache: false,
                async: false,
                type: "post",
                url: VOD.urlConfig.redirect,
                timeout: 10000,
                data: {"request": JSON.stringify({url: VOD.Constant.thirdUrl_legoProgramIdUrl, type: "post", params: {
                    data: JSON.stringify(dataJson)
                }, needCookie: true}), timeSign: new Date().getTime()},
                success: function (res) {
                    if (res.code != 'A00000') {
                        //alert(res.msg);
                        VOD.Plugin.tips("error", res.msg);
                    } else {
                        var programId = res.data.programId;
                        if (!programId) {
                            //alert('乐高返回的programId为空!');
                            VOD.Plugin.tips("error", '乐高返回的programId为空!');
                            return false;
                        }

                        var newPA = {
                            title: title,
                            cat: channel,
                            alb: albumId,
                            enableClound: VOD.Util.getEnableCloundVal(),
                            priority: priority,
                            video_dpi: video_dpi,
                            uid: uid,
                            partnerId: partnerId,
                            episodeType: episodeType
                        }

                        //提交数据给刘之红
                        if (VOD.Util.postData(settings.subData, newPA, pic, programId, dataSubmit)) {
//////////////////////////制作数据统计///////////////////////////////////////////
                            var sSrc = $("#img-" + sTime).attr("src"),
                                eSrc = $("#img-" + eTime).attr("src");

                            var s_fp_pos = sSrc.lastIndexOf('/') + 1,
                                s_fp_time = sSrc.substr(VOD.Config.Global.fp_pos, 10),
                                e_fp_pos = eSrc.lastIndexOf('/') + 1,
                                e_fp_time = eSrc.substr(VOD.Config.Global.fp_pos, 10);

                            var seconds = (parseInt(e_fp_time) - parseInt(s_fp_time));

                            $.each(global.d_sty2Data, function (n, adData) {
                                var adStartTime = adData.sTime, adEndTime = adData.eTime;
                                if (sTime < adStartTime && eTime > adEndTime) {

                                    var sSrc = $("#img-" + adStartTime).attr("src"),
                                        ads_fp_pos = sSrc.lastIndexOf('/') + 1,
                                        ads_fp_time = sSrc.substr(ads_fp_pos, 10),
                                        eSrc = $("#img-" + adEndTime).attr("src"),
                                        ade_fp_pos = eSrc.lastIndexOf('/') + 1,
                                        ade_fp_time = eSrc.substr(ade_fp_pos, 10);
                                    var ad_seconds = (parseInt(ade_fp_time) - parseInt(ads_fp_time));
                                    seconds = seconds - ad_seconds;
                                }
                            });

                            VOD.Util.dl_click("/api/st?bs=1&st=1&prid=" + programId
                                    + "&pr_name=" + encodeURIComponent(newPA.title)
                                    + "&pr_mins=" + seconds
                                    + "&cname=" + $('input[name=categoryName]').val()
                                    + "&u=" + VOD.Util.getUserName()
                                    + "&cp=" + paramsData._channel_name_str
                                    + "&bt=" + new Date(parseInt(s_fp_time) * 1000).format("yyyy-MM-dd hh:mm:ss")
                                    + "&et=" + new Date(parseInt(e_fp_time) * 1000).format("yyyy-MM-dd hh:mm:ss")
                                    + "&dst=" + new Date().format("yyyy-MM-dd hh:mm:ss")
                                    + "&ablum_name=" + album
                                    + "&s_a_dot=" + ""                   //广告开始
                                    + "&s_m_dot=" + sTime					//打点手动开始
                                    + "&e_a_dot=" + ""						//广告结束
                                    + "&e_m_dot=" + eTime					//打点手动结束
                                    + "&ad_info=" + delAdStr
                            );

//////////////////////////OCR统计///////////////////////////////////////////
                            if (!$("#ocr").hasClass("disabled")) {
                                var ocrTitle = VOD.Config.Global.statisticOcrTitle;
                                VOD.Config.Global.statisticOcrTitle = "";
                                VOD.Util.dl_click("/api/st?bs=1&st=3&programId=" + programId
                                        + "&programName=" + encodeURIComponent(newPA.title)
                                        + "&channelId=" + paramsData._channel_id
                                        + "&channelName=" + paramsData._channel_name_str
                                        + "&categoryName=" + $('input[name=categoryName]').val()
                                        + "&ocrTitle=" + encodeURIComponent(ocrTitle)
                                        + "&userTitle=" + encodeURIComponent(newPA.title)
                                        + "&user=" + VOD.Util.getUserName()
                                );
                            }
//////////////////////////长视频智能分析统计///////////////////////////////////////////
// sty2Data 缓存sty2数据
// d_sty2Data 缓存提交后的广告头和尾

                            var headerCompleteNumbers = headerIncompleteNumbers = headerFaultNumbers = 0,
                                lastCompleteNumbers = lastIncompleteNumbers = lastFaultNumbers = 0,
                                adCompleteNumbers = adIncompleteNumbers = adFaultNumbers = 0;

// 计算广告智能分析正确数
                            var eq_sTime, eq_eTime,
                                headerSty2Index, headerSty2Length, headerListIndex,
                                lastSty2Index, lastSty2Length, lastListIndex,
                                gtSty2Flag, ltSty2Flag;
                            var sty2DataList = global.sty2Data.list;
                            if (global.channelInfo.length == 0 || global.channelInfo[0].sty2 == 1) {

                                $.each(global.d_sty2Data, function (n, adData) {
                                    var sVid = $('.' + adData.sTime + '-jump').attr("id").split("-")[1],
                                        eVid = $('.' + adData.eTime + '-jump').attr("id").split("-")[1];
                                    console.log("sty2DataList ,length ", sty2DataList.length);
                                    $.each(sty2DataList, function (i, item) {
                                        console.log("itemvideo_list ,length ", (item.video_list == null), item.video_list.length);
                                        $.each(item.video_list, function (j, sty2Id) {
                                            if (item.type == VOD.Config.adLib) {
                                                var length = item.video_list.length;
                                                if (sVid == sty2Id) {
                                                    headerSty2Index = i;
                                                    headerListIndex = j;
                                                    headerSty2Length = length;
                                                    eq_sTime = sty2Id;
                                                } else if (eVid == sty2Id) {
                                                    lastSty2Index = i;
                                                    lastListIndex = j;
                                                    lastSty2Length = length;
                                                    eq_eTime = sty2Id;
                                                }
                                                if (j == 0 && sVid < sty2Id) {
                                                    ltSty2Flag = true;
                                                }
                                                if (j == length - 1 && eVid > sty2Id) {
                                                    gtSty2Flag = true;
                                                }
                                            }
                                        });
                                    });


                                    if (eq_sTime == null && eq_eTime == null) {
                                        if (ltSty2Flag && gtSty2Flag) {
                                            adIncompleteNumbers++;
                                        } else {
                                            adFaultNumbers++;
                                        }

                                    } else if (eq_sTime == null || eq_eTime == null) {
                                        adIncompleteNumbers++;
                                    } else if (eq_sTime != null && eq_eTime != null) {
                                        var adRound = eq_eTime - eq_sTime + 1;
                                        if (headerSty2Index == lastSty2Index && adRound == headerSty2Length) {
                                            adCompleteNumbers++;
                                        } else if (headerSty2Index == lastSty2Index && adRound != headerSty2Length) {

                                            adIncompleteNumbers++;
                                        } else if (headerSty2Index != lastSty2Index) {
                                            if (headerListIndex != 0 || lastListIndex != lastSty2Length - 1) {
                                                adIncompleteNumbers++;
                                            } else {
                                                var index = headerSty2Index;
                                                var flag = true;
                                                while (flag) {
                                                    if (index == lastSty2Index) {
                                                        adCompleteNumbers++;
                                                        flag = false;
                                                    } else {
                                                        var videoList = sty2DataList[index].video_list;
                                                        var nextVideoList = sty2DataList[index + 1].video_list;
                                                        if ((nextVideoList[0] - videoList[videoList.lenth - 1]) >= 2) {
                                                            adIncompleteNumbers++;
                                                            flag = false;
                                                        }
                                                    }
                                                    index++;
                                                }
                                            }
                                        }
                                    }

                                });
// 广告智能分析提交数请空
                                global.d_sty2Data = [];
                                headerSty2Index = null;
                                eq_sTime = null;
                                eq_eTime = null;

                                sVid = $('.' + sTime + '-jump').attr("id").split("-")[1];
                                eVid = $('.' + eTime + '-jump').attr("id").split("-")[1];
// 计算片头和片尾正确数
                                console.log("sty2DataList ,length ", sty2DataList.length);
                                $.each(sty2DataList, function (i, item) {
                                    console.log("itemvideo_list ,length ", (item.video_list == null), item.video_list.length);
                                    $.each(item.video_list, function (j, sty2Id) {
                                        if (item.type == VOD.Config.adLibHead) {
                                            if (sVid == sty2Id) {
                                                headerSty2Index = j;
                                                eq_sTime = sty2Id;
                                            }
                                        }
                                        if (item.type == VOD.Config.adLibTail) {
                                            if (eVid == sty2Id) {
                                                lastSty2Index = j;
                                                lastSty2Length = item.video_list.length;
                                                eq_eTime = sty2Id;
                                            }
                                        }
                                    });
                                });

                                if (eq_sTime == null) {
                                    headerFaultNumbers++;
                                } else if (eq_sTime != null && headerSty2Index == 0) {
                                    headerCompleteNumbers++;
                                } else {
                                    headerIncompleteNumbers++;
                                }

                                if (eq_eTime == null) {
                                    lastFaultNumbers++;
                                } else if (eq_eTime != null && lastSty2Index == lastSty2Length - 1) {
                                    lastCompleteNumbers++;
                                } else {
                                    lastIncompleteNumbers++;
                                }

                                VOD.Util.dl_click("/api/st?bs=1&st=2&channelId=" + paramsData._channel_id
                                        + "&channelName=" + paramsData._channel_name_str
                                        + "&channelCode=" + paramsData.channel_name
                                        + "&programId=" + programId
                                        + "&programName=" + encodeURIComponent(newPA.title)
                                        + "&categoryName=" + $('input[name=categoryName]').val()
                                        + "&albumName=" + album
                                        + "&programTime=" + seconds
                                        + "&headerCompleteNumbers=" + headerCompleteNumbers
                                        + "&headerIncompleteNumbers=" + headerIncompleteNumbers
                                        + "&headerFaultNumbers=" + headerFaultNumbers
                                        + "&lastCompleteNumbers=" + lastCompleteNumbers
                                        + "&lastIncompleteNumbers=" + lastIncompleteNumbers
                                        + "&lastFaultNumbers=" + lastFaultNumbers
                                        + "&adCompleteNumbers=" + adCompleteNumbers
                                        + "&adIncompleteNumbers=" + adIncompleteNumbers
                                        + "&adFaultNumbers=" + adFaultNumbers
                                        + "&user=" + VOD.Util.getUserName()
                                );
                            }
/////////////////////////////end//////////////////////////////////////////////////////

                            //alert('打点成功');
                            VOD.Plugin.tips("success", '打点成功');
                            VOD.AccurateFrame.fgTipRemove();
                            return true;
                        }
                    }
                },
                dataType: "json",
                error: function (XMLHttpRequest, status) {
                    //alert('网络错误,请稍后再提交！');
                    if (status == 'timeout') {
                        ajaxTimeoutTest.abort();
                        VOD.Plugin.tips("error", '接口/peditor/submit调用超时10秒未响应！请联系乐高相关负责人员！');
                    } else {
                        VOD.Plugin.tips("error", '网络错误,请稍后再提交！');
                    }
                    $('#tab3_submit').removeAttr('disabled').html('提交');
                }
            });

        },
        // 获取字符串长度
        subCharacterLength: function (str, charLength) {
            var titleReg = new RegExp("[\\u4E00-\\u9FFF]");
            var countLength = 0;
            var indexCount = 0;
            var tmpLength = 0;
            for (var i = 0, l = str.length; i < l; i++) {
                // 0-127 ASCII char
                // 128-255 ASCII expand char
                if (str.charCodeAt(i) > 255) {
                    tmpLength = 2;
                } else {
                    tmpLength = 1;
                }
                if (countLength + tmpLength > charLength) {
                    break;
                }
                indexCount++;
                countLength += tmpLength;
            }
            return str.substr(0, indexCount);
        },

        // 填加背景色
        addBackgroundColor: function (options) {
            var defaults = {
                st: 0,
                et: 0,
                color: '',
                removeColor: ''
            };
            options = $.extend({}, defaults, options);

            for (i = options.st; i <= options.et; i++) {
                if (!options.removeColor) {
                    $('#img-' + i).addClass(options.color);
                } else {
                    $('#img-' + i).removeClass(options.color);
                }
            }
        },

        postData: function (list, newPA, imageId, programId, addData) {
            var sList = '[' + list.join(",") + "]";
            var paramsData = VOD.Dao.getParamsData();
            var settings = VOD.Dao.settings;
            var accurateFrame = VOD.AccurateFrame.getAccurateFrame();
            var dotData = VOD.Dao.getDotData();
            var pData = {
                'title': newPA.title,
                'categoryId': newPA.cat,
                'albumId': newPA.alb,
                'code': paramsData.channel_name,
                'programId': programId,
                'userId': VOD.Util.getUserId() + "",
                'from_client': true,
                'key': settings.taskid,
                'list': sList,
                'imageId': imageId,
                'head': accurateFrame.head,
                'end': accurateFrame.end,
                'priority': newPA.priority,
                'video_dpi': newPA.video_dpi,
                'uid': newPA.uid,
                'partnerId': newPA.partnerId,
                'episodeType': newPA.episodeType,
                'enableClound': newPA.enableClound
            };
            VOD.AccurateFrame.doReset();
            $.ajax({
                cache: false,
                async: false,
                type: "post",
                url: dotData.dotUrl,
                data: pData,
                success: function (data) {
                    if (data.error != 0) {
                        VOD.Plugin.tips("error", data.error);
                        return false;
                    } else {
                        if (VOD.Util.isTab3Show()) {
                            $("#tab3_submit").html('成功');
                            $("li[aria-controls=tab3]").hide();
                            $("#tab3").hide();
                            var elementId = $("span[name=tabName]").html().replace(/序号|发布/g, "");
                            $("#navDiv").tabs({active: 1});
                            VOD.Util.delNews(elementId, true);
                        } else {
                            $('#addInfo').html('成功');
                            $('#cForm').find('input[type=text]').each(function () {
                                if ($(this).attr('name') == 'albumName' || $(this).attr('name') == 'categoryName' || $(this).attr('name') == 'location') {

                                }
                                else {
                                    $(this).val('');
                                }
                            });
                            $('textarea[name=desc]').val('');
                            $('textarea[name=fantasyTitle]').val('');
                        }
                        VOD.Util.addInfo(addData, 'add');
                        settings.index++;
                        return true;
                    }
                },
                dataType: "json",
                error: function () {
                    VOD.Plugin.tips("error", '编码服务器网络错误,请稍后再提交！');
                    $('#addInfo').removeAttr('disabled').html('提交');
                }
            });
            return true;
        },
        doReview: function (sTime, eTime, deleteFlag) {
            var data = {
                '起始帧': sTime,
                '结束帧': eTime
            };
            if (!VOD.Util.validAddInfo(data)) {
                return false;
            }
            if (parseInt(sTime) > parseInt(eTime)) {
                VOD.Plugin.tips("error", '起始帧不能大于结束帧');
                return false;
            }
            var numTime = $('#picNum').text();
            if (parseInt(eTime) >= parseInt(numTime)) {
                VOD.Plugin.tips("error", '结束帧不存在,不能预览');
                return false;
            }
            VOD.Player.splitData(sTime, eTime, deleteFlag); //去除删除部分
            VOD.Player.review();
        },

        getReTranscodeConfirmVal: function () {
            if ($('input[name=reTranscodeConfirm]').prop('checked')) {
                return 1;
            } else {
                return 0;
            }
        },
        getEnableCloundVal: function () {
            if ($('input[name=enableClound]').prop('checked')) {
                return 0;
            } else {
                return 1;
            }
        },
        getUserId: function () {
            return auth.baseInfo.authInfo.uid;
        },
        getUserName: function () {
            return auth.baseInfo.authInfo.userName;
        },

        /**
         * 限制输入框中字符个数，一个汉字相当于两个字符，wordCount是最多允许的汉字个数
         * @param  {jquery  object}  $des  限制字符个数的输入框
         * @param  {Number}  wordCount     允许输入的最多字字符数（一个汉字等于两个字符）
         * @param  {Boolean} isFilterChars 是否过滤输入内容，true过滤，false或undefined不过滤
         * @param  {Array}  filterChars    需要过滤的字符集，如['$','.']，意为全局过滤 $ *                                 和 .
         */
        limitWordCount: function ($des, charCount, isFilterChars, filterChars, bindHandler) {
            var self = this;
            charCount = charCount || 450;
            var t = function (textarea) {
                var $textarea = $(textarea);
                var text = $textarea.val();
                if (isFilterChars) {
                    text = Com.string.filterSpecialChars(text, filterChars);
                    $textarea.val(text);
                }
                var length = Com.string.getStrLength(text);
                if (length > charCount) {
                    $textarea.val(self.subCharacterLength(text, charCount));
                }
                text = $textarea.val();
                length = Com.string.getStrLength(text);
                if (bindHandler == null) {
                    $textarea.parent().find('span.leftWordsCount').text(charCount - length);
                } else {
                    bindHandler(charCount - length);
                }
            };
            $des.bind({
                input: function () {
                    //   console.log("input handler ")
                    t(this);
                },
                propertychange: function () {
                    //    console.log("propertychange handler ")
                    t(this);
                },
                change: function () {
                    //  console.log("change handler ")
                    t(this);
                },
                focusout: function () {
                    //  console.log("focusout handler ")
                    setTimeout(function () {
                        t($des)
                    }, 100);
                },
                keyup: function () {
                    //   console.log("keyup handler ")
                    t(this);
                }
            });
            $des.keyup();
        },

        binSearchOcrTitle: function (start, end) {
            return this.binSearchTitle(VOD.Dao.settings.g_ocrList, start, end)
        },
        binSearchAcrTitle: function (start, end) {
            return this.binSearchTitle(VOD.Dao.settings.g_acrList, start, end)
        },
        binSearchTitle: function (arr, start, end) {
            var titleList = [];
            var tmp = [];
            var len = arr.length;
            if (len) {
                for (var i in arr) {
                    if (start >= arr[i]['first'] && start <= arr[i]['last'] || arr[i]['first'] >= start && arr[i]['last'] <= end || end >= arr[i]['first'] && end <= arr[i]['last']) {
                        tmp[arr[i]['title']] = i; // 去重复
                    }
                }
                for (var j in tmp) {
                    titleList.push(j);
                }
            }
            return titleList;
        },
        updateGridAdvert: function () {
            $('#advert_list').clearGridData();
            $('#advert_list')[0].addJSONData(VOD.Config.PageBeanAdvert.getCur())
        },
        updateGridFrame: function () {
            $('#frame_list').clearGridData();
            $('#frame_list')[0].addJSONData(VOD.Config.PageBeanFrame.getCur())
        },
        updateGridNews: function (object) {
            if (object != null) {
                var findData = VOD.Config.PageBeanNews.findData("regId", object.id);
                for (var key in object) {
                    if (key != "id" && findData.hasOwnProperty(key)) {
                        findData[key] = object[key];
                    }
                }
                $('#news_list').setRowData(object.id, object);
            }
        },
        recoverTab3: function (key, lastData) {
            switch (key) {
                case "st":
                    $("input[name=tab3_inpoint]").val(lastData.st)
                    break;
                case "et":
                    $("input[name=tab3_outpoint]").val(lastData.et)
                    break;
                case "pic":
                    $("input[name=tab3_imageId]").val(lastData.pic)
                    break;

            }
        },
        updateTab3Check: function (object) {
            var numTime = $('#picNum').text();
            var lastData = VOD.NewsHighlight.getLastOption();
            if (object.value.length == 0) {
                this.recoverTab3(object.key, lastData)
                return;
            }
            if (isNaN(object.value)) {
                this.recoverTab3(object.key, lastData)
                return;
            }

            object.value = parseInt(object.value);
            VOD.NewsHighlight.setNewOption(object);
        },
        updateTab3Form: function (object) {
            if (!this.isTab3Show()) {
                return;
            }
            if (object != null) {
                var findData = VOD.Config.PageBeanNews.findData("regId", object.id);
                for (var key in object) {
                    if (key != "id" && findData.hasOwnProperty(key)) {
                        switch (key) {
                            case "sTime":
                                $("input[name=tab3_inpoint]").val(object[key]);
                                break;
                            case  "eTime":
                                $("input[name=tab3_outpoint]").val(object[key]);
                                break;
                            case "pic":
                                $("input[name=tab3_imageId]").val(object[key]);
                                $("#cover_img").attr("src", $("#img-" + object[key]).attr("src"));
                                break;
                        }
                    }
                }

            }
        },
        updateInfoComplete: function (endTime, infoNum) {
            var checkTime = new Date().getTime() - 600000;
            var isOld = endTime < this.formatDateTimeFormat(new Date(checkTime));
            var infostr = "";
            if (!isOld) {
                infostr = VOD.Config.INFO_UN_COMPLETE
            } else {
                infostr = infoNum == 0 ? VOD.Config.INFO_COMPLETE : VOD.Config.INFO_COMPLETE_WAIT_DO;
            }
            $("a[action-name=info_complete]").html(infostr.replace("N", infoNum));
        },

        updateObjectData: function (newData, oldData) {
            for (var key in newData) {
                if (oldData.hasOwnProperty(key)) {
                    oldData[key] = newData[key];
                }
            }
        },
        isTab2Show: function () {
            return $("li[aria-controls=tab2]").attr("aria-selected") == "true"
        },
        isTab3Show: function () {
            return $("li[aria-controls=tab3]").attr("aria-selected") == "true"
        },
        doQuickAdd: function () {
            VOD.Dao.settings.reg_last_id++;
            var newObj = { title: "[]", sTime: 0, eTime: 1, pic: 0, id: 0, regId: VOD.Dao.settings.reg_last_id, checked: false };
            VOD.Config.PageBeanNews.addNewOne(newObj);
            $("#news_list")[0].addJSONData(VOD.Config.PageBeanNews.getCur());
            VOD.Util.doNewsGridScroll(newObj.regId);
        },
        doRowSelected: function (element) {
            var tempChild = VOD.Config.PageBeanNews.findData("regId", parseInt(element.value));
            tempChild.checked = $(element).is(":checked");
        },
        doSelectedAll: function (flag) {
            var elementArr = $("#news_list").find("input[type=checkbox]");
            $.each(elementArr, function (i, element) {
                if ($(element).is(":checked") == !flag) {
                    $(element).click();
                }
            })
        },

        doQuickMerge: function () {
            var selElementArr = $("#news_list").find("input[type=checkbox]:checked");
            var childArr = [];
            var tempChild = null;
            $.each(selElementArr, function (i, elem) {
                tempChild = VOD.Config.PageBeanNews.findData("regId", parseInt(elem.value));
                childArr.push(tempChild);
            })
            childArr.sort(VOD.Config.SORT_RULE.asc_news_sTime);
            if (childArr.length == 1) {
                return;
            }
            var checkContinue = -1;
            var toRemoveArr = [];
            var newTitleArr = [];
            var childTitleArr = null;
            var endFrameData = null;
            $.each(childArr, function (i, tempChild) {
                if (checkContinue == -1) {
                    checkContinue = tempChild.eTime;
                    endFrameData = tempChild.frameData;
                } else if (checkContinue + 1 >= tempChild.sTime) {
                    if (checkContinue < tempChild.eTime) {
                        checkContinue = tempChild.eTime;
                        endFrameData = tempChild.frameData;
                    } else if (endFrameData == null) {
                        endFrameData = tempChild.frameData;
                    } else {
                        if (tempChild.frameData != null && tempChild.frameData.end != endFrameData.end) {
                            console.log("结尾关键帧不同，清空")
                            endFrameData = null;
                        }
                    }
                } else {
                    VOD.Plugin.tips("error", "条目不连续，不能合并");
                    checkContinue = -2;
                    return false
                }
                if (tempChild.id > 0) {
                    toRemoveArr.push(tempChild.id);
                } else if (tempChild.isMergeMode) {
                    toRemoveArr = toRemoveArr.concat(tempChild.toRemoveArr);
                }
                childTitleArr = JSON.parse(tempChild.title);

                if (childTitleArr.length > 0) {
                    if (tempChild.showTitle != "") {
                        if (childTitleArr.indexOf(tempChild.showTitle) == -1) {
                            childTitleArr = [ tempChild.showTitle ].concat(childTitleArr);
                        }
                    }
                    newTitleArr = newTitleArr.concat(childTitleArr);
                } else {
                    if (tempChild.showTitle != "") {
                        newTitleArr.push(tempChild.showTitle);
                    }
                }
            });
            if (checkContinue > 0) {
                var firstData = childArr[0];
                var newObj = {title: JSON.stringify(newTitleArr), sTime: firstData.sTime, eTime: checkContinue,
                    pic: firstData.pic, regId: firstData.regId, id: 0,
                    isMergeMode: true, children: childArr, toRemoveArr: toRemoveArr,
                    frameData: endFrameData
                };
                $("#news_list").clearGridData();
                VOD.Util.mergeNewsGridData([newObj], childArr)
                VOD.Util.setHighLight(newObj);
                VOD.Util.fromLIstJump(newObj.sTime);
                VOD.Util.doNewsGridScroll(newObj.regId);
                $("#news_list").jqGrid('setSelection', newObj.regId);
            }
        },
        doSourceMerge: function (lastSource, newSource) {
            if (VOD.Config.PageBeanTemp == null) {
                VOD.Config.PageBeanTemp = VOD.Util.createPageBean();
            }
            var pageBean = VOD.Config.PageBeanTemp;
            pageBean.setNewData(newSource);
            var tempElement = null;
            var retSource = [];
            var retFlag = false;
            $.each(lastSource, function (i, element) {
                retFlag = VOD.Util.updateRef(element, pageBean);
                if (retFlag) {
                    retSource.push(element);
                    if (element.isMergeMode) {
                        element.regId = element.children[0].regId;
                        $.each(element.toRemoveArr, function (index, childId) {
                            tempElement = pageBean.findData("id", childId);
                            pageBean.delOne(tempElement);
                        })
                    } else if (element.id > 0) {
                        tempElement = pageBean.findData("id", element.id);
                        pageBean.delOne(tempElement);
                    }
                }
            })
            var rest = pageBean.getSource();
            retSource = retSource.concat(rest);
            retSource.sort(VOD.Config.SORT_RULE.asc_news_regId);
            return retSource;
        },
        updateRef: function (element, pageBean) {
            var retFlag = false;
            if (element.isMergeMode == true) {
                $.each(element.children, function (i, child) {
                    retFlag = VOD.Util.updateRef(child, pageBean);
                    if (!retFlag) {
                        return false;
                    }
                })
            } else if (element.id > 0) {
                var temp = pageBean.findData("id", element.id);
                if (temp != null) {
                    element.regId = temp.regId;
                    retFlag = true;
                }
            } else {
                VOD.Dao.settings.reg_last_id++;
                element.regId = VOD.Dao.settings.reg_last_id;
                retFlag = true;
            }
            return retFlag;
        },
        doChangeTitle: function (element) {
            var $target = $(element);
            var targetId = null;
            if ($target.attr("name") == "tab3_title") {
                // targetId = VOD.NewsHighlight.getLastOption().id;
                targetId = parseInt($("span[name=tabName]").html().replace(/序号|发布/g, ""));
            } else {
                targetId = parseInt($target.attr("data-id"))
            }
            var rowData = VOD.Config.PageBeanNews.findData("regId", targetId);
            rowData.showTitle = $target.val();
            $("#news_list").setRowData(rowData.regId, { title: rowData.title, regId: rowData.regId });
        },
        undoMerge: function (mergeId) {
            var rowData = VOD.Config.PageBeanNews.findData("regId", parseInt(mergeId));
            $.each(rowData.children, function (i, element) {
                element.checked = false;
            })
            VOD.Util.mergeNewsGridData(rowData.children, [rowData])
            VOD.Util.clearHighLight();
            VOD.Util.doNewsGridScroll(mergeId);
            if ($("li[aria-controls=tab3]").is(":visible")) {
                var elementId = $("span[name=tabName]").html().replace(/序号|发布/g, "");
            }
            if (mergeId == parseInt(elementId)) {
                $("li[aria-controls=tab3]").hide();
            }
        },
        mergeNewsGridData: function (addArr, delArr) {
            $.each(delArr, function (i, element) {
                VOD.Config.PageBeanNews.delOne(element)
            })
            $.each(addArr, function (i, element) {
                VOD.Config.PageBeanNews.addNewOne(element)
            })
            VOD.Config.PageBeanNews.sortData(VOD.Config.SORT_RULE.asc_news_regId);
            $("#news_list")[0].addJSONData(VOD.Config.PageBeanNews.getCur());
        },
        clearHighLight: function () {
            VOD.NewsHighlight.setHighLight(null);
        },
        doNewsGridScroll: function (rowid) {
            var bdiv = $("#tab2").find(".ui-jqgrid-bdiv");
            if (bdiv[0].scrollHeight <= bdiv[0].clientHeight) {
                return;
            }
            rowid = rowid + ""
            var allData = $("#news_list").jqGrid("getRowData");
            var interrupt = 0;
            for (var i = 0; i < allData.length; i++) {
                if (allData[i].hidden_news_id == rowid) {
                    interrupt = i;
                    break;
                }
            }
            bdiv.scrollTop(interrupt / allData.length * bdiv[0].scrollHeight);
        },
        doNewsGridResize: function () {
            if ($("#news_list").length > 0) {
                var showHeight = $(window).height() - 890 + 355;
                if (showHeight < 60) {
                    showHeight = 60;
                }
                $("#news_list").setGridHeight(showHeight)
            }
        },
        bindFrameData: function (frameData) {
            var bindId = VOD.NewsHighlight.getLastOption().id;
            var bindData = VOD.Config.PageBeanNews.findData("regId", bindId);
            bindData.frameData = $.extend(true, {}, frameData);
        },

        readPublishFrameData: function (rowId) {
            if (rowId == null) {
                rowId = $("span[name=tabName]").html().replace(/序号|发布/g, "");
            }
            var bindData = VOD.Config.PageBeanNews.findData("regId", rowId);
            if (bindData != null && bindData.frameData != null) {
                VOD.AccurateFrame.readFrameData(bindData.frameData);
            } else {
                VOD.AccurateFrame.doReset();
            }
        },
        fillDefaultTitle:function(){
            var settings = VODNew.Dao.settings;
            var c_sTime = $('input[name=eTime]').val();
            var s_sTime = $('input[name=sTime]').val();
            if (s_sTime == '' && isNaN(s_sTime)){
                return
            }
            if (c_sTime != '' && !isNaN(c_sTime)) {
                if($("input[name=videoName]").val().length > 0){
                    return ;
                }
                if ($('input[name=videotype]:checked').val() == -1) {
                    var show = settings.taskid + '-' + VODNew.Dao.getParamsData().channel_name + '-' + settings.today + '-' + s_sTime + '-' + c_sTime;
                    $('input[name=videoName]').val(show);
                    var ocrFirstTitle = VODNew.Util.binSearchOcrTitle(s_sTime, c_sTime).shift();
                    if (ocrFirstTitle) {
                        $("input[name=videoName]").val(ocrFirstTitle);
                        $("input[name=videoName]").attr("eut", encodeURIComponent(ocrFirstTitle));
                    }
                }
            }
        }
    })
})
;